package problem3;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

import problem2.Apple;
import problem2.RedApple;

public class Main {
	public static void main(String[] args) {
		testWork();
	}
	
	public static <T extends Apple> Collection<T> collectionWithGreaterThan(Collection<? extends T> in, T sample) {
		Collection<T> newcol = null;
		if (in!=null && sample!=null) {
			newcol = new ArrayList<T>();
		for (T elem: in) {
			if (elem.compareTo(sample)>0) newcol.add(elem);
		}
		}
		return newcol;
	}
	
	public static void testWork() {
		
		Collection<Apple> cnum = Arrays.asList(new Apple[]{new Apple(5), new Apple(10), new Apple(4), 
			                                    new Apple(12), new RedApple(7), new RedApple(3)});
		System.out.println(cnum);
		Collection<Apple> newcol = collectionWithGreaterThan(cnum,new Apple(6));
		System.out.println("new Collection: "+newcol);
	}
}
